$(function() {
	layui.use([ 'form', 'layer' ], function(form, layer) {
		// 监听提交
		form.on('submit(login)', function(data) {//data.field.id为空是新增,否则为修改
			var params = {
					username : data.field.username,
					password : data.field.password
			};
			CoreUtil.sendAjax("/operator/login", JSON.stringify(params), function(res) {
					if('0' == res.code){
						window.sessionStorage.setItem("user",JSON.stringify(res.data.user));
						location.href=res.data.toPage
					}else{
						layer.msg("用户名或密码错误！",{icon:1,time:500});
					}
			}, "POST", false);
			return false;
		});
		
      });
    
});